<?php

namespace App\Models\cms;

use App\Models\ContentHasColumn;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Content
 * @package App\Models
 */
class Content extends Model
{
    use SoftDeletes;

    const CONTENT_TYPE_PIC = 'ContentPicture';
    /**
     * 对应表名
     *
     * @var string
     */
    public $table = 'cms_contents';

    public $fillable = [
        'title',
        'tags',
        'content_detail_type',
        'content_detail_id',
        'keywords',
        'category_full_path',//新加入的
        'view_count',//新加入的
        'author'//新加入的
    ];

    public function content_detail()

    {
        return $this->morphTo()->withTrashed();
    }


    /**
     * 分类
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function categories()
    {
        return $this->belongsToMany(Category::class, 'cms_content_has_categories', 'content_id', 'category_id')->withTrashed();
    }
    public function categoryLabel(){
        return $this->hasMany(ContentHasCategory::class,'content_id');
    }
    public function navigation(){
        return $this->hasOne(Navigation::class,'point_content_id');
    }
}
